/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.code.client2server;

import com.jili.ubert.dao.db.NewOrder;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.FieldType;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import java.io.IOException;

/**
 *
 * @author ChengJiLi
 */
public class BasketOrder {
    @Protobuf(fieldType = FieldType.SINT32, order=1, required = false)
    private int basketid;
    @Protobuf(fieldType = FieldType.SINT32, order=2, required = false)
    private int total = 0;
    @Protobuf(fieldType = FieldType.OBJECT, order=3, required = false)
    private NewOrder[] orders;
    public void setBasketID(int basketid){
        this.basketid = basketid;
    }
    /*
    public void setTotal(int total){
        this.total = total;
    }
    */
    public void setOrders(NewOrder[] orders){
        this.orders = orders;
    }
    public int getBasketID(){
        return basketid;
    }
    public int getTotal(){
        return total;
    }
    public NewOrder[] getOrders(){
        return orders;
    }
    public void BasketOrder(NewOrder[] orders){
        this.orders = orders;
        total = orders.length;
    }
    public void AddOrder(NewOrder order){
        orders[total++] = order;
        //total+=1;
    }
    public void RemoveOrder(int i){
        orders[i] = null;
    }
    public byte[] EnCode(BasketOrder msg) throws IOException{
        Codec<BasketOrder> Lcode = ProtobufProxy.create(BasketOrder.class);
        return Lcode.encode(msg);
    }
    public BasketOrder DeCode(byte[] data) throws IOException{
        Codec<BasketOrder> Lcode = ProtobufProxy.create(BasketOrder.class);
        return Lcode.decode(data);
        
    }
}
